package com.File_io;

public class Beer {
    public static  int totalNumber;
    public static  int lastBottleNumber;
    public static int lastCoverNumber;
    public static void main(String[] args) {
     buy(10);
        System.out.println(totalNumber);
        System.out.println("最后的瓶盖数是"+lastCoverNumber);
        System.out.println("最后的瓶子数是"+lastBottleNumber);
    }
    public static void buy(int money){
        int buyNumber=money/2;
        totalNumber+=buyNumber;
        int allBottleNumber=buyNumber+lastBottleNumber;
        int allCoverNumber=buyNumber+lastCoverNumber;
        int allMoney=0;
        if(allBottleNumber>=2){
            allMoney+=(allBottleNumber/2)*2;
        }
        if(allCoverNumber>=4){
            allMoney+=(allCoverNumber/4)*2;
        }
        lastBottleNumber=allBottleNumber%2;
        lastCoverNumber=allCoverNumber%4;
        if(allMoney>=2){
            buy(allMoney);
        }
    }
}
